package com.siruier.boss.ui.tool.image.select.service.impl

import android.content.Context
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import com.luck.picture.lib.PictureSelector
import com.siruier.boss.api.core.ApiComplete
import com.siruier.boss.api.core.ApiError
import com.siruier.boss.api.core.ApiProcess
import com.siruier.boss.api.core.ApiRequest
import kotlinx.coroutines.CoroutineScope

class ImageSelectActivity(var activity: FragmentActivity) : AbstractImageSelect() {

    override val context: Context = activity
    override val pictureSelector: PictureSelector = PictureSelector.create(activity)
    override fun <T> launchUI(
        block: suspend CoroutineScope.() -> T,
        apiObserver: Observer<ApiProcess<T>>?,
        error: ApiError?,
        complete: ApiComplete?,
    ) {
        ApiRequest(activity.lifecycleScope, block, error, complete, apiObserver).launchUI()
    }

}